package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbContentMapper;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.pojo.TbContentCategoryExample;
import com.dongdongshop.pojo.TbContentExample;
import com.dongdongshop.service.ContentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.List;

@Service
@org.springframework.stereotype.Service
public class ContentServiceImpl implements ContentService {

    private static final Logger logger = LoggerFactory.getLogger(ContentServiceImpl.class);

    @Resource
    private TbContentMapper tbContentMapper;

    @Override
    public PageInfo<TbContent> getListContent(Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<TbContent> tbContents = tbContentMapper.selectByExample(new TbContentExample());
        PageInfo<TbContent> pageInfo = new PageInfo<>(tbContents);
        logger.info("执行成功");
        return pageInfo;
    }

    @Override
    public int insertContent(TbContent content) {
        return tbContentMapper.insertSelective(content);
    }

    @Override
    public TbContent selectInfoById(Long id) {
        return tbContentMapper.selectByPrimaryKey(id);
    }

    //
    @Override
    public int deleteBatch(Long[] ids) {
        return tbContentMapper.deleteContentBatch(ids);
    }

    @Override
    public int updateContentInfo(TbContent content) {
        return tbContentMapper.updateByPrimaryKeySelective(content);
    }

    @Override
    public int updateStatusById(Long[] ids, String status) {
        return tbContentMapper.updateStatusById(ids,status);
    }

    @Override
    public List<TbContent> getListMyCarousel() {
        return tbContentMapper.getListMyCarousel();
    }

    @Override
    public List<TbContent> listTodayContent() {
        return tbContentMapper.listTodayContent();
    }

    @Override
    public List<TbContent> listFavoriteContent() {
        return tbContentMapper.listFavoriteContent();
    }

    @Override
    public List<TbContent> listInterestContent() {
        return tbContentMapper.listInterestContent();
    }

    @Override
    public List<TbContent> listTab1Content() {
        return tbContentMapper.listTab1Content();
    }
}
